import _ajax from '@/api/request'
// 联想搜索补全
function suggestion (data) {
  return _ajax({
    url: '/app/v1_0/suggestion',
    params: data
  })
}
// 问答搜索
function search (data) {
  return _ajax({
    url: '/app/v1_0/search',
    params: data
  })
}
// 问答文章点赞
function articleLikings (data) {
  return _ajax({
    url: '/app/v1_0/article/likings',
    method: 'post',
    needToken: true,
    data
  })
}
// 举报文章
function articleReports (data) {
  return _ajax({
    url: '/app/v1_0/article/reports',
    method: 'post',
    needToken: true,
    data
  })
}
// 文章详情
function articlesArticleId (id) {
  return _ajax({
    url: `/app/v1_0/articles/${id}`
  })
}
// 获取文章评论
function articleComments (data) {
  return _ajax({
    url: '/app/v1_0/comments',
    params: data
  })
}
// 发布评论
function comments (data) {
  return _ajax({
    url: '/app/v1_0/comments',
    method: 'post',
    needToken: true,
    data
  })
}
// 取消文章点赞
function articleLikingsId (id) {
  return _ajax({
    url: `/app/v1_0/article/likings/${id}`,
    method: 'delete',
    needToken: true
  })
}
// 收藏文章
function articleCollections (data) {
  return _ajax({
    url: '/app/v1_0/article/collections',
    method: 'post',
    needToken: true,
    data
  })
}
// 取消收藏文章
function articleCollectionsId (id) {
  return _ajax({
    url: `/app/v1_0/article/collections/${id}`,
    method: 'delete',
    needToken: true
  })
}
// 点赞评论或评论回复
function commentLikings (data) {
  return _ajax({
    url: '/app/v1_0/comment/likings',
    method: 'post',
    needToken: true,
    data
  })
}
// 取消点赞评论或评论回复
function commentLikingsId (id) {
  return _ajax({
    url: `/app/v1_0/comment/likings/${id}`,
    method: 'delete',
    needToken: true
  })
}
// 关注作者
function userFollowings (data) {
  return _ajax({
    url: '/app/v1_0/user/followings',
    method: 'post',
    needToken: true,
    data
  })
}
// 取消关注作者
function userFollowingsId (id) {
  return _ajax({
    url: `/app/v1_0/user/followings/${id}`,
    method: 'delete',
    needToken: true
  })
}
// 猜你喜欢
function articles (data) {
  return _ajax({
    url: '/app/v1_1/articles',
    params: data
  })
}

export {
  search,
  suggestion,
  articleLikings,
  articleReports,
  articlesArticleId,
  articleLikingsId,
  articleComments,
  comments,
  articleCollections,
  articleCollectionsId,
  commentLikings,
  commentLikingsId,
  userFollowings,
  userFollowingsId,
  articles
}
